package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserHeartrateDataMapper;
import com.splic.product.domain.UserHeartrateData;
import com.splic.product.service.UserHeartrateDataService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户心率数据Service业务层处理
 * 
 * @author singe
 * @date 2022-01-04
 */
@Service
public class UserHeartrateDataServiceImpl implements UserHeartrateDataService
{
    @Autowired
    private UserHeartrateDataMapper userHeartrateDataMapper;

    /**
     * 查询用户心率数据
     * 
     * @param id 用户心率数据主键
     * @return 用户心率数据
     */
    @Override
    public UserHeartrateData selectUserHeartrateDataById(Long id)
    {
        return userHeartrateDataMapper.selectUserHeartrateDataById(id);
    }

    /**
     * 查询用户心率数据列表
     * 
     * @param userHeartrateData 用户心率数据
     * @return 用户心率数据
     */
    @Override
    public List<UserHeartrateData> selectPageList(UserHeartrateData userHeartrateData)
    {
        return userHeartrateDataMapper.selectUserHeartrateDataList(userHeartrateData);
    }

    /**
     * 查询用户心率数据列表
     *
     * @param userHeartrateData 用户心率数据
     * @return 用户心率数据
     */
    @Override
    public List<UserHeartrateData> selectUserHeartrateDataList(UserHeartrateData userHeartrateData)
    {
        return userHeartrateDataMapper.selectUserHeartrateDataList(userHeartrateData);
    }

    /**
     * 新增用户心率数据
     * 
     * @param userHeartrateData 用户心率数据
     * @return 结果
     */
    @Override
    public int insert(UserHeartrateData userHeartrateData)
    {
        userHeartrateData.setCreateTime(DateUtils.getNowDate());
        return userHeartrateDataMapper.insert(userHeartrateData);
    }

    /**
     * 修改用户心率数据
     * 
     * @param userHeartrateData 用户心率数据
     * @return 结果
     */
    @Override
    public int update(UserHeartrateData userHeartrateData)
    {
        userHeartrateData.setUpdateTime(DateUtils.getNowDate());
        return userHeartrateDataMapper.update(userHeartrateData);
    }


    /**
     * 删除用户心率数据信息
     * 
     * @param id 用户心率数据主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userHeartrateDataMapper.deleteById(id);
    }
    /**
     * 修改用户心率数据
     *
     * @param userHeartrateData 用户心率数据信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserHeartrateData userHeartrateData)
    {
        if(userHeartrateData.getId() != null){
            userHeartrateData.setUpdateTime(new Date());
            return userHeartrateDataMapper.update(userHeartrateData);
        }else{
            userHeartrateData.setCreateTime(new Date());
            return userHeartrateDataMapper.insert(userHeartrateData);
        }
    }
}
